package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.google.web.bindery.requestfactory.shared.ProxyFor;
import com.nc.delivery_project.server.domain.NaturalPerson;
import com.nc.delivery_project.server.service.NaturalPersonService;
import com.nc.delivery_project.shared.servicelocator.NaturalPersonServiceLocator;

/**
 * Created by miroshnik on 1/28/2015.
 */
public class NaturalPersonLocator extends Locator<NaturalPerson, Integer> {
    
    @Override
    public NaturalPerson create(Class<? extends NaturalPerson> clazz) {
        return new NaturalPerson();
    }

    @Override
    public NaturalPerson find(Class<? extends NaturalPerson> clazz, Integer id) {
        return ((NaturalPersonService) new NaturalPersonServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<NaturalPerson> getDomainType() {
        return NaturalPerson.class;
    }

    @Override
    public Integer getId(NaturalPerson domainObject) {
        return domainObject.getNaturalPersonId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(NaturalPerson domainObject) {
        return domainObject.getNaturalPersonId();
    }
}
